﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <script src="~/Areas/Back/lib/layui/layui.js"></script>
    <link href="~/Areas/Back/lib/css/layui.css" rel="stylesheet" />
    <title>编辑</title>
</head>
<body>
    <div class="layui-container" style="margin-top:20px; margin-bottom:150px">
        @*onsubmit="return false" 禁止form表单提交，我们要使用ajax*@
        <form class="layui-form" id="addForm" onsubmit="return false">
            @*用户名*@
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" readonly value="@ViewBag.A.UserName" id="UserName" class="layui-input" />
                </div>
            </div>
            @*旧密码*@
            <div class="layui-form-item">
                <label class="layui-form-label">旧密码</label>
                <div class="layui-input-block">
                    <input type="password" class="layui-input" id="Password" />
                </div>
            </div>
            @*新密码*@
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <input type="password" id="NewPassword" class="layui-input" />
                </div>
            </div>
            @*按钮*@
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="subAdd">提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</body>
<script>
    layui.use(['form','layedit','upload'], function () {
        var form = layui.form;
        var layedit = layui.layedit;
        var upload = layui.upload;
        var layer = layui.layer;
        var $ = layui.$;
        //开始处理点击提交
        form.on('submit(subAdd)', function () {
            //ajax请求
            $.ajax({
                url: "EditPWD",
                method: "post",
                dataType: "json",
                data: {
                    UserName: $("#UserName").val(),
                    Password: $("#Password").val(),
                    NewPassword: $("#NewPassword").val(),
                },
                success: function (res) {
                    if (res.success == true) {
                        layer.msg(res.msg);
                        window.parent.location.href = "Login";
                    }
                    else {
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });
    });
</script>
</html>